from wordcloud import  WordCloud
import jieba
import numpy as np
from PIL import Image
with open('av85369921.txt', mode='r', encoding='utf-8') as f:
    text = f.read()
cutlist = jieba.lcut(text)
word_str = ' '.join(cutlist)
mask = np.array(Image.open('timg.png'))
wcd = WordCloud(
    background_color='white',
    max_font_size=100,
    max_words=700,
    width=500,
    height=800,
    font_path='msyh.ttc',
    mask=mask,
    mode="RGBA",
    random_state=30,
    scale=2,
    colormap='Reds'
)

# print(word_str)
wcd.generate(word_str)
wcd.recolor()
wcd.to_file('好看的慈云.png')
